<template>
  <div class="finishi-order">
    <el-table :data="tableData" style="width: 100%">
      <el-table-column label="id" prop="id" align="center"> </el-table-column>
      <el-table-column label="订单编号" prop="oid" align="center">
      </el-table-column>
      <el-table-column label="图片" width="120" align="center">
        <template slot-scope="scope">
          <img
            :src="require(`/public/commodity/${scope.row.pic}`)"
            alt=""
            width="100%"
          />
        </template>
      </el-table-column>
      <el-table-column label="商品名称" prop="title" align="center">
      </el-table-column>
      <el-table-column label="品类" prop="type" align="center">
      </el-table-column>
      <el-table-column label="购买数量" prop="count" align="center">
      </el-table-column>
      <el-table-column label="总额" prop="price_total" align="center">
      </el-table-column>
      <el-table-column label="购买时间" align="center">
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{
            moment(scope.row.order_time).format("YYYY-MM-DD HH:mm:ss")
          }}</span>
        </template>
      </el-table-column>
      <el-table-column label="状态" align="center">
        <template slot-scope="scope">
          <el-tag>{{ scope.row.order_status }}</el-tag>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center">
        <template slot-scope="scope">
          <el-button
            size="mini"
            @click="
              handleEdit(scope.$index, scope.row);
              dialogVisible = true;
            "
            >订单详情</el-button
          >
          <!-- 查看订单用户详情 -->
          <el-dialog title="订单详情" :visible.sync="dialogVisible">
            <section>
              <div>
                <img src="" alt="" srcset="" /><br />
                颜色：<span>红色</span> 尺码：<span>37</span>
              </div>
              <div>
                <h1>买家的评论</h1>
                <p>asdhkashdkj</p>
              </div>
              <div>
                <h1>回复评论</h1>
                <el-form ref="form">
                  <el-form-item>
                    <el-input
                      type="textarea"
                      v-model="form.comments"
                    ></el-input>
                  </el-form-item>
                  <el-form-item>
                    <el-button type="primary" @click="onSubmit"
                      >立即回复</el-button
                    >
                  </el-form-item>
                </el-form>
              </div>
            </section>
          </el-dialog>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
export default {
  data() {
    return {
      form: {
        comments: "",
      },
      tableData: [],
      userData: [],
      user: "",
      phone: "",
      user_name: "",
      email: "",
      gender: "",
      addr: "",
      dialogVisible: false,
      oid: "",
    };
  },
  mounted() {
    this.getfinish();
  },
  methods: {
    onSubmit() {
      console.log("submit!");
    },
    handleEdit(row, index) {
      console.log(index.id, row);
    },
    handleDelete(index, row) {
      console.log(index, row);
    },
    getfinish() {
      let url = `http://localhost:8000/stroll/finish?oid=${this.oid}`;
      this.axios.get(url).then((res) => {
        this.tableData = res.data;
      });
    },
    finishOid(oid) {
      this.oid = oid;
      this.getfinish();
    },
  },
};
// 不能用挂载加载两个路由
</script>
<style lang="scss" scoped>
section {
  display: flex;
  justify-content: space-evenly;
  > div {
    width: 33%;
    height: 150px;
  }
  > div:first-child {
    border-right: 1px solid rgba(177, 177, 177, 0.5);
    > img {
      width: 100px;
      height: 100px;
    }
  }
  > div:nth-child(2) {
    border-right: 1px solid rgba(177, 177, 177, 0.5);
  }
  > div:last-child {
  }
}
</style>